package com.shushan.pages.bean;

import com.android.net.bean.NetBaseBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: ExerciseRecordListBean
 * @Desciption: //练习记录列表页数据bean
 * @author: zhangshihao
 * @date: 2018-04-23
 */
public class ExerciseRecordListBean extends NetBaseBean {

    public int type;//练习类型
    public int answer_num;//练习多少次
    public int exercise_num;//总共答多少题
    public int right_num;//正确题目总计

    public List<LastExerciseRecordBean> lastBeans;

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if (jsonObject != null) {
            answer_num = jsonObject.optInt("answer_num");
            exercise_num = jsonObject.optInt("exercise_num");
            right_num = jsonObject.optInt("right_num");
            JSONArray syncLastArray = jsonObject.optJSONArray("last");
            if (syncLastArray != null && syncLastArray.length() > 0) {
                lastBeans = new ArrayList<>();
                for (int i = 0; i < syncLastArray.length(); i++) {
                    LastExerciseRecordBean lastBean = new LastExerciseRecordBean();
                    lastBean.initByJson((JSONObject) syncLastArray.get(i));
                    lastBeans.add(lastBean);
                }
            }
        }
    }
}
